package com.wangwei;

import com.alibaba.druid.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@SpringBootApplication
@MapperScan("com.wangwei.mapper")
public class DressSystemApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(DressSystemApplication.class, args);
        log.info("                                                             _   \n" +
                "                                                            (_)  \n" +
                " _   _   __  ,--.   _ .--.   .--./)      _   _   __  .---.  __   \n" +
                "[ \\ [ \\ [  ]`'_\\ : [ `.-. | / /'`\\;     [ \\ [ \\ [  ]/ /__\\\\[  |  \n" +
                " \\ \\/\\ \\/ / // | |, | | | | \\ \\._//  _   \\ \\/\\ \\/ / | \\__., | |  \n" +
                "  \\__/\\__/  \\'-;__/[___||__].',__`  (_)   \\__/\\__/   '.__.'[___] \n" +
                "                           ( ( __))                              \n");
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if (StringUtils.isEmpty(path)) {
            path = "";
        }
        String swaggerUiPath = "/doc.html"; // 修改为您的Swagger UI路径

        String localUrl = "http://localhost:" + port + path + swaggerUiPath;
        String externalUrl = "http://" + ip + ":" + port + path + swaggerUiPath;

        // 打印启动日志，包含Swagger文档的访问URL
        System.out.println("\n----------------------------------------------------------\n\t" +
                "Application is running! Access URLs:\n\t" +
                "Local访问网址: \t\thttp://localhost:" + port + path + "\n\t" +
                "External访问网址: \thttp://" + ip + ":" + port + path + "\n\t" +
                "Swagger文档地址: \t" + localUrl + "\n\t" +
                "----------------------------------------------------------");

    }
}
